<template>
    <div>
        <el-form :model="OfficialSealData" label-width="120px" :rules="rules" ref="UpdateOfficialSealData_refs"
                 :disabled="IsSee">
            <el-row :gutter="24">
                <el-col :span="8">
                    <el-form-item label="公章" prop="OfficialsealId">
                        <el-select placeholder="请选择" v-model="OfficialSealData.OfficialsealId" filterable>
                            <el-option v-for="v in ApplicantDatas"
                                       :label="v.Name" :value="v.Id"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="申请人" prop="ApplicantId">
                        <el-select placeholder="请选择" v-model="OfficialSealData.ApplicantId" filterable>
                            <el-option v-for="v in $store.state.AllUsers" v-if="v.InternshipState!=8"
                                       :label="v.UserName" :value="v.Id"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="开始时间" prop="StartTime">
                        <el-date-picker
                                v-model="OfficialSealData.StartTime"
                                type="datetime"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                placeholder="选择日期时间">
                        </el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="结束时间" prop="EndTime">
                        <el-date-picker
                                v-model="OfficialSealData.EndTime"
                                type="datetime"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                placeholder="选择日期时间">
                        </el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="使用地点" prop="UseAddress">
                        <el-input v-model="OfficialSealData.UseAddress"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="事由" prop="Reason">
                        <el-input v-model="OfficialSealData.Reason"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col align="center">
                    <el-button type="success" @click="UpdateSubmit_enent">提交</el-button>
                </el-col>
            </el-row>
        </el-form>
    </div>
</template>

<script>
    import * as publicjs from "../../../../public/Scriput/Public";

    export default {
        name: "UpdateOfficialSealData",
        props: {
            IsSee: {
                type: Boolean,
                required: true,
            },
            OfficialSealData: {
                type: Object,
                required: true,
            },
            ApplicantDatas: {
                type: Array,
                required: true,
            },
        },
        data() {
            return {
                rules: {
                    OfficialsealId: [{required: true, message: '请选择公章', trigger: 'change'},],
                    ApplicantId: [{required: true, message: '请选择申请人', trigger: 'change'},],
                    StartTime: [{required: true, message: '请选择开始时间', trigger: 'change'},],
                    EndTime: [{required: true, message: '请选择结束时间', trigger: 'change'},],
                    UseAddress: [{required: true, message: '请输入使用地点', trigger: 'change'},],
                }
            }
        },
        watch: {},
        created() {

        },
        methods: {
            //窗体关闭表格处理
            dialog_close() {
                // 重置表单数据
                this.$refs['UpdateOfficialSealData_refs'].resetFields()
            },
            //确认修改
            UpdateSubmit_enent() {
                this.$refs['UpdateOfficialSealData_refs'].validate(vali => {
                    if (vali) {
                        let loadding = this.openLoading();
                        this.$http.post('OfficialSeal/UpdataOfficialSealRecord', {officialSealRecord: this.OfficialSealData}).then(res => {
                            loadding.close();
                            if (res.data.msg.IsSuccess) {
                                this.$message.success(res.data.msg.Msg)
                                this.dialog_close()
                                this.$parent.$parent.formdata()
                                this.$parent.$parent.Update_OfficialSealData.dialog = false
                            } else {
                                this.$message.warning(res.data.msg.Msg)
                            }
                        })
                    }
                })
            },
        },
    }
</script>

<style scoped>
</style>
